package com.bestcem.xm.user.grpc.client.convert;

import com.bestcem.xm.om.grpc.v1.services.GetIndustryContactResponse;
import com.bestcem.xm.om.grpc.v1.services.GetUserIndustryInfoResponse;
import com.bestcem.xm.om.grpc.v1.services.Industry;
import com.bestcem.xm.om.grpc.v1.services.ListIndustriesRequest;
import com.bestcem.xm.user.grpc.client.dto.IndustryDTO;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.NullValueCheckStrategy;

import java.util.List;

/**
 * Industry转换类
 *
 * @author wangyunyun <yunyun.wang@idiaoyan.com>
 * @version v1.0
 * @date 2022/5/12 17:37
 */
@Mapper(componentModel = "spring", nullValueCheckStrategy = NullValueCheckStrategy.ALWAYS)
public interface IndustryGrpcConvert {

    @Mapping(target = "industryId", source = "industry.id")
    @Mapping(target = "code", source = "industry.code")
    @Mapping(target = "name", source = "industry.name")
    @Mapping(target = "salesEmails", source = "emailsList")
    @Mapping(target = "contacts", source = "phonesList")
    IndustryDTO getIndustryContactRes2Dto(GetIndustryContactResponse response);

    @Mapping(target = "industryId", source = "info.id")
    @Mapping(target = "name", source = "info.name")
    @Mapping(target = "code", source = "info.code")
    IndustryDTO getUserIndustryInfoRes2Dto(GetUserIndustryInfoResponse response);

    @Mapping(target = "id", source = "industryId")
    @Mapping(target = "name", source = "name")
    @Mapping(target = "code", source = "code")
    ListIndustriesRequest dto2ListIndustriesReq(IndustryDTO industryDTO);

    @Mapping(target = "industryId", source = "id")
    @Mapping(target = "name", source = "name")
    @Mapping(target = "code", source = "code")
    IndustryDTO industryGrpc2Dto(Industry industry);

    List<IndustryDTO> industryGrpcs2Dtos(List<Industry> industryList);
}
